#pragma once
//============================================================================
// Copyright (C) 2009-2013 Brett R. Jones 
// All Rights Reserved
//
// You may redistribute and/or modify for non commercial and commercial uses 
// provided this copyright notice remains in place and is not modified
//
// This code is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// brettjones1900@gmail.com
// http://www.p2panarchy.com
//============================================================================

#include <VxUtilLib/VxPktHdr.h>

#define RC_SYS_PKT_MAX_LEN							16384 // some routers wont route pkts greater than this
//=== system service packet types ===//
#define MIN_RC_SYS_PKT_TYPE							0x4000
#define RC_SYS_PKT_TYPE_DIE							0x4000

#define RC_SYS_PKT_TYPE_AUTH						0x4001
#define RC_SYS_PKT_TYPE_ANN_LIST					0x4002
#define RC_SYS_PKT_TYPE_ANNOUNCE					0x4003

#define RC_SYS_PKT_TYPE_FIND_NODE					0x4004

#define RC_SYS_PKT_TYPE_OFFER_SYSTEM_MSG			0x4005
#define RC_SYS_PKT_TYPE_OFFER_PLUGIN				0x4006	
#define RC_SYS_PKT_TYPE_OFFER_STATUS				0x4007

#define RC_SYS_PKT_TYPE_ANN_APP_UPDATE				0x4008
#define RC_SYS_PKT_TYPE_PATCH						0x4009
#define RC_SYS_PKT_TYPE_NODE_LIST					0x400a
#define RC_SYS_PKT_TYPE_PING						0x400b		// ping uses pkt announce with type set to RC_SYS_PKT_TYPE_PING
#define RC_SYS_PKT_TYPE_PONG						0x400c		// pong uses pkt announce with type set to RC_SYS_PKT_TYPE_PONG
#define RC_SYS_PKT_TYPE_PROXY_SERVICE_REQ			0x400d
#define RC_SYS_PKT_TYPE_PROXY_SERVICE_REPLY			0x400e
#define RC_SYS_PKT_TYPE_PROXY_CONNECT_REQ			0x400f
#define RC_SYS_PKT_TYPE_PROXY_CONNECT_REPLY			0x4010
#define RC_SYS_PKT_TYPE_PROXY_USER_DISCONNECT		0x4011

#define RC_SYS_PKT_TYPE_SEARCH_REQ					0x4012
#define RC_SYS_PKT_TYPE_SEARCH_REPLY				0x4013
#define RC_SYS_PKT_TYPE_FIND_FILE_REQ				0x4014
#define RC_SYS_PKT_TYPE_FIND_FILE_REPLY				0x4015

#define MAX_RC_SYS_PKT_TYPE							0x4015

#define MAX_SERVICE_PKT_TYPE_CNT					0x0016 // maximum packet types used by Engine

//=== packet category bits ===//
// packets 0x300 - 0x1fff  reserved for plugins

// header for all pkts
class RcSysPktHdr : public VxPktHdr
{
public:
	//! return true if pkt type is in range of system packets and valid length that is a multiple of 16 bytes
    bool isValidPktLen( void );

	//! return true if pkt type is in range of system packets and valid length that is a multiple of 16 bytes
    bool isValidSysPkt( void );

	//! return true if pkt type is in range and valid length that is a multiple of 16 bytes
    bool isValidPluginPkt( void );

	//! return true if pkt type is in range and valid length that is a multiple of 16 bytes
    bool isValidRcPkt( void );

	// return true if is announce packet
    bool IsPktAnnounce( void );
};

//http statuses
#define RC_SYS_PKT_REQ_STATUS_OK				200 //"200 OK"
#define RC_SYS_PKT_REQ_STATUS_CREATED			201	//"201 Created"
#define RC_SYS_PKT_REQ_STATUS_ACCEPTED			202	//"202 Accepted"
#define RC_SYS_PKT_REQ_ERR_NO_CONTENT			204	//"204 No Content"
#define RC_SYS_PKT_REQ_ERR_MOVED_PERM			301	//"301 Moved Permanently"
#define RC_SYS_PKT_REQ_ERR_MOVED_TEMP			302	//"301 Moved Temporarily"
#define RC_SYS_PKT_REQ_ERR_NOT_MODIFIED			304 //"304 Not Modified"
#define RC_SYS_PKT_REQ_ERR_BAD_REQUEST			400 //"400 Bad Request"
#define RC_SYS_PKT_REQ_ERR_UNAUTHORIZED			401 //"401 Unauthorized"
#define RC_SYS_PKT_REQ_ERR_FORBIDDEN			403 //"403 Forbidden"
#define RC_SYS_PKT_REQ_ERR_NOT_FOUND			404 //"404 Not Found"
#define RC_SYS_PKT_REQ_ERR_INTERNAL_SERVER_ERR	500	//"500 Internal Server Error"
#define RC_SYS_PKT_REQ_ERR_NOT_IMPLEMENTED		501 //"501 Not Implemented"
#define RC_SYS_PKT_REQ_ERR_BAD_GATEWAY			502 //"502 Bad Gateway"
#define RC_SYS_PKT_REQ_ERR_SERVICE_UNAVAIL		503 //"503 Service Unavailable"
//custom statuses
#define RC_SYS_PKT_REQ_ERR_BANDWITH_LIMIT		600 //"600 Refused because of Bandwidth limit
#define RC_SYS_PKT_REQ_ERR_CONNECT_LIMIT		601	//"601 Refused because of Connection limit
#define RC_SYS_PKT_REQ_ERR_SERVICE_DISABLED		602	//"602 Refused because Service was disabled
#define RC_SYS_PKT_REQ_ERR_ALL_THREADS_BUSY		603	//"603 Refused because all threads busy


#define PKT_TYPE_TC_PLUGIN_OFFSET				PKT_TC_PLUGIN_BIT




